package top.go2do.auth.business.user.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import top.go2do.auth.business.user.module.UserRolePO;

import java.util.List;
import java.util.Set;

/**
 * @Description
 * @Author xingyj
 * @CreateTime 2025/3/17 10:21
 */
public interface UserRoleRepository extends JpaRepository<UserRolePO, Long>, JpaSpecificationExecutor<UserRolePO> {
    List<UserRolePO> findByUserIdIn(Set<Long> userIdSet);

    @Transactional
    @Modifying
    @Query("DELETE FROM UserRolePO ur WHERE ur.userId = ?1") // 根据email删除
    int deleteByUserId(Long userId);
}
